<!DOCTYPE HTML>
<html lang="en" >
    
    <head>
        
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <title>使用加载器 | Hello, Webpack!</title>
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <meta name="description" content="">
        <meta name="generator" content="GitBook 2.4.1">
        
        
        <meta name="HandheldFriendly" content="true"/>
        <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
        <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">
        
    <link rel="stylesheet" href="../gitbook/style.css">
    
        
        <link rel="stylesheet" href="../gitbook/plugins/gitbook-plugin-highlight/website.css">
        
    
    

        
    
    
    <link rel="next" href="../start/using-plugins.html" />
    
    
    <link rel="prev" href="../start/vendor-modules.html" />
    

        
    </head>
    <body>
        
        
    <div class="book" data-level="1.7" data-basepath=".." data-revision="Fri Nov 13 2015 15:10:50 GMT+0800 (CST)">
    

<div class="book-summary">
    <div class="book-search" role="search">
        <input type="text" placeholder="Type to search" class="form-control" />
    </div>
    <nav role="navigation">
        <ul class="summary">
            
            
            
            

            

            
    
        <li class="chapter " data-level="0" data-path="index.html">
            
                
                    <a href="../index.html">
                
                        <i class="fa fa-check"></i>
                        
                        Introduction
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1" data-path="start/index.html">
            
                
                    <a href="../start/index.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.</b>
                        
                        开始
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.1" data-path="start/motivation.html">
            
                
                    <a href="../start/motivation.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.1.</b>
                        
                        Motivation
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="start/what-is-webpack.html">
            
                
                    <a href="../start/what-is-webpack.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.2.</b>
                        
                        What is webpack?
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="start/installation.html">
            
                
                    <a href="../start/installation.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.3.</b>
                        
                        Installation
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="start/usage.html">
            
                
                    <a href="../start/usage.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.4.</b>
                        
                        Usage
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="start/require-modules.html">
            
                
                    <a href="../start/require-modules.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.5.</b>
                        
                        Require Modules
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="start/vendor-modules.html">
            
                
                    <a href="../start/vendor-modules.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.6.</b>
                        
                        Vendor Modules
                    </a>
            
            
        </li>
    
        <li class="chapter active" data-level="1.7" data-path="start/using-loaders.html">
            
                
                    <a href="../start/using-loaders.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.7.</b>
                        
                        使用加载器
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="start/using-plugins.html">
            
                
                    <a href="../start/using-plugins.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.8.</b>
                        
                        Using Plugins
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.9" data-path="start/dev-tools.html">
            
                
                    <a href="../start/dev-tools.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.9.</b>
                        
                        Dev Tools
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.10" data-path="start/troubleshooting.html">
            
                
                    <a href="../start/troubleshooting.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.10.</b>
                        
                        Troubleshooting
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2" data-path="tutorials-and-example/index.html">
            
                
                    <a href="../tutorials-and-example/index.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.</b>
                        
                        TUTORIALS AND EXAMPLES
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.1" data-path="tutorials-and-example/getting-started.html">
            
                
                    <a href="../tutorials-and-example/getting-started.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.1.</b>
                        
                        Getting started
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.2" data-path="tutorials-and-example/list-of-tutorials.html">
            
                
                    <a href="../tutorials-and-example/list-of-tutorials.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.2.</b>
                        
                        List of tutorials
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.3" data-path="tutorials-and-example/examples.html">
            
                
                    <a href="../tutorials-and-example/examples.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.3.</b>
                        
                        examples
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="3" data-path="guides/index.html">
            
                
                    <a href="../guides/index.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.</b>
                        
                        GUIDES
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="3.1" data-path="guides/commonjs.html">
            
                
                    <a href="../guides/commonjs.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.1.</b>
                        
                        CommonJs
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.2" data-path="guides/amd.html">
            
                
                    <a href="../guides/amd.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.2.</b>
                        
                        AMD
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.3" data-path="guides/webpack-for-browserify-users.html">
            
                
                    <a href="../guides/webpack-for-browserify-users.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.3.</b>
                        
                        webpack for browserify users
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.4" data-path="guides/code-splitting.html">
            
                
                    <a href="../guides/code-splitting.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.4.</b>
                        
                        Code Splitting
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.5" data-path="guides/stylesheets.html">
            
                
                    <a href="../guides/stylesheets.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.5.</b>
                        
                        Stylesheets
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.6" data-path="guides/optimization.html">
            
                
                    <a href="../guides/optimization.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.6.</b>
                        
                        Optimization
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.7" data-path="guides/long-term-caching.html">
            
                
                    <a href="../guides/long-term-caching.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.7.</b>
                        
                        Long-term Caching
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.8" data-path="guides/how-to-write-a-loader.html">
            
                
                    <a href="../guides/how-to-write-a-loader.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.8.</b>
                        
                        How to write a loader
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.9" data-path="guides/how-to-write-a-plugin.html">
            
                
                    <a href="../guides/how-to-write-a-plugin.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.9.</b>
                        
                        How to write a plugin
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.10" data-path="guides/multiple-entry-points.html">
            
                
                    <a href="../guides/multiple-entry-points.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.10.</b>
                        
                        Multiple entry points
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.11" data-path="guides/library-and-externals.html">
            
                
                    <a href="../guides/library-and-externals.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.11.</b>
                        
                        Library and externals
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.12" data-path="guides/shimming-modules.html">
            
                
                    <a href="../guides/shimming-modules.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.12.</b>
                        
                        Shimming modules
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.13" data-path="guides/testing.html">
            
                
                    <a href="../guides/testing.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.13.</b>
                        
                        Testing
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.14" data-path="guides/build-performance.html">
            
                
                    <a href="../guides/build-performance.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.14.</b>
                        
                        Build performance
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.15" data-path="guides/hot-module-replacement-with-webpack.html">
            
                
                    <a href="../guides/hot-module-replacement-with-webpack.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.15.</b>
                        
                        Hot Module Replacement with webpack
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.16" data-path="guides/comparison.html">
            
                
                    <a href="../guides/comparison.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.16.</b>
                        
                        Comparison
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="4" data-path="webpack-with/index.html">
            
                
                    <a href="../webpack-with/index.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.</b>
                        
                        WEBPACK WITH
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="4.1" data-path="webpack-with/grunt.html">
            
                
                    <a href="../webpack-with/grunt.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.1.</b>
                        
                        grunt
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.2" data-path="webpack-with/gulp.html">
            
                
                    <a href="../webpack-with/gulp.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.2.</b>
                        
                        gulp
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.3" data-path="webpack-with/bower.html">
            
                
                    <a href="../webpack-with/bower.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.3.</b>
                        
                        bower
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.4" data-path="webpack-with/karma.html">
            
                
                    <a href="../webpack-with/karma.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.4.</b>
                        
                        karma
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="5" data-path="lists/index.html">
            
                
                    <a href="../lists/index.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.</b>
                        
                        LISTS
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="5.1" data-path="lists/loader-conventions.html">
            
                
                    <a href="../lists/loader-conventions.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.1.</b>
                        
                        loader conventions
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.2" data-path="lists/list-of-loaders.html">
            
                
                    <a href="../lists/list-of-loaders.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.2.</b>
                        
                        List of loaders
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.3" data-path="lists/list-of-plugins.html">
            
                
                    <a href="../lists/list-of-plugins.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.3.</b>
                        
                        List of plugins
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.4" data-path="lists/list-of-tutorials.html">
            
                
                    <a href="../lists/list-of-tutorials.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.4.</b>
                        
                        List of tutorials
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.5" data-path="lists/list-of-hints.html">
            
                
                    <a href="../lists/list-of-hints.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.5.</b>
                        
                        List of hints
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="6" data-path="api/index.html">
            
                
                    <a href="../api/index.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.</b>
                        
                        API
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="6.1" data-path="api/configuration.html">
            
                
                    <a href="../api/configuration.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.1.</b>
                        
                        Configuration
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.2" data-path="api/cli.html">
            
                
                    <a href="../api/cli.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.2.</b>
                        
                        CLI
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.3" data-path="api/node.js-api.html">
            
                
                    <a href="../api/node.js-api.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.3.</b>
                        
                        Node.js API
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.4" data-path="api/api-in-modules.html">
            
                
                    <a href="../api/api-in-modules.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.4.</b>
                        
                        API in modules
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.5" data-path="api/loaders.html">
            
                
                    <a href="../api/loaders.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.5.</b>
                        
                        Loaders
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.6" data-path="api/plugins.html">
            
                
                    <a href="../api/plugins.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.6.</b>
                        
                        Plugins
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.7" data-path="api/context.html">
            
                
                    <a href="../api/context.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.7.</b>
                        
                        Context
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.8" data-path="api/resolving.html">
            
                
                    <a href="../api/resolving.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.8.</b>
                        
                        Resolving
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.9" data-path="api/hot-module-replacement.html">
            
                
                    <a href="../api/hot-module-replacement.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.9.</b>
                        
                        Hot Module Replacement
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="7" data-path="dev-tools/index.html">
            
                
                    <a href="../dev-tools/index.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.</b>
                        
                        Dev Tools
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="7.1" data-path="dev-tools/webpack-dev-server.html">
            
                
                    <a href="../dev-tools/webpack-dev-server.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.1.</b>
                        
                        webpack-dev-server
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="7.2" data-path="dev-tools/webpack-dev-middleware.html">
            
                
                    <a href="../dev-tools/webpack-dev-middleware.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.2.</b>
                        
                        webpack-dev-middleware
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="8" data-path="development/index.html">
            
                
                    <a href="../development/index.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>8.</b>
                        
                        DEVELOPMENT
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="8.1" data-path="development/changelog.html">
            
                
                    <a href="../development/changelog.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>8.1.</b>
                        
                        Changelog
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="8.2" data-path="development/roadmap.html">
            
                
                    <a href="../development/roadmap.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>8.2.</b>
                        
                        Roadmap
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="8.3" data-path="development/ideas.html">
            
                
                    <a href="../development/ideas.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>8.3.</b>
                        
                        Ideas
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="9" data-path="contributing/index.html">
            
                
                    <a href="../contributing/index.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>9.</b>
                        
                        Contributing
                    </a>
            
            
        </li>
    


            
            <li class="divider"></li>
            <li>
                <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
                    Published with GitBook
                </a>
            </li>
            
        </ul>
    </nav>
</div>

    <div class="book-body">
        <div class="body-inner">
            <div class="book-header" role="navigation">
    <!-- Actions Left -->
    <a href="#" class="btn pull-left toggle-summary" aria-label="Table of Contents"><i class="fa fa-align-justify"></i></a>
    <a href="#" class="btn pull-left toggle-search" aria-label="Search"><i class="fa fa-search"></i></a>
    
    <div id="font-settings-wrapper" class="dropdown pull-left">
        <a href="#" class="btn toggle-dropdown" aria-label="Font Settings"><i class="fa fa-font"></i>
        </a>
        <div class="dropdown-menu font-settings">
    <div class="dropdown-caret">
        <span class="caret-outer"></span>
        <span class="caret-inner"></span>
    </div>

    <div class="buttons">
        <button type="button" id="reduce-font-size" class="button size-2">A</button>
        <button type="button" id="enlarge-font-size" class="button size-2">A</button>
    </div>

    <div class="buttons font-family-list">
        <button type="button" data-font="0" class="button">Serif</button>
        <button type="button" data-font="1" class="button">Sans</button>
    </div>

    <div class="buttons color-theme-list">
        <button type="button" id="color-theme-preview-0" class="button size-3" data-theme="0">White</button>
        <button type="button" id="color-theme-preview-1" class="button size-3" data-theme="1">Sepia</button>
        <button type="button" id="color-theme-preview-2" class="button size-3" data-theme="2">Night</button>
    </div>
</div>

    </div>

    <!-- Actions Right -->
    
    <div class="dropdown pull-right">
        <a href="#" class="btn toggle-dropdown" aria-label="Share"><i class="fa fa-share-alt"></i>
        </a>
        <div class="dropdown-menu font-settings dropdown-left">
            <div class="dropdown-caret">
                <span class="caret-outer"></span>
                <span class="caret-inner"></span>
            </div>
            <div class="buttons">
                <button type="button" data-sharing="twitter" class="button">
                    Share on Twitter
                </button>
                <button type="button" data-sharing="google-plus" class="button">
                    Share on Google
                </button>
                <button type="button" data-sharing="facebook" class="button">
                    Share on Facebook
                </button>
                <button type="button" data-sharing="weibo" class="button">
                    Share on Weibo
                </button>
                <button type="button" data-sharing="instapaper" class="button">
                    Share on Instapaper
                </button>
            </div>
        </div>
    </div>
    

    
    <a href="#" target="_blank" class="btn pull-right google-plus-sharing-link sharing-link" data-sharing="google-plus" aria-label="Google"><i class="fa fa-google-plus"></i></a>
    
    
    <a href="#" target="_blank" class="btn pull-right facebook-sharing-link sharing-link" data-sharing="facebook" aria-label="Facebook"><i class="fa fa-facebook"></i></a>
    
    
    <a href="#" target="_blank" class="btn pull-right twitter-sharing-link sharing-link" data-sharing="twitter" aria-label="Twitter"><i class="fa fa-twitter"></i></a>
    
    
    


    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="../" >Hello, Webpack!</a>
    </h1>
</div>

            <div class="page-wrapper" tabindex="-1" role="main">
                <div class="page-inner">
                
                
                    <section class="normal" id="section-">
                    
                        <h1 id="%E5%8A%A0%E8%BD%BD%E5%99%A8%E6%98%AF%E4%BB%80%E4%B9%88">&#x52A0;&#x8F7D;&#x5668;&#x662F;&#x4EC0;&#x4E48;</h1>
<p>&#x52A0;&#x8F7D;&#x5668;&#x7528;&#x6765;&#x8F6C;&#x6362;&#x4F60;web&#x5E94;&#x7528;&#x7A0B;&#x5E8F;&#x4E2D;&#x7684;&#x8D44;&#x6E90;&#x6587;&#x4EF6;&#xFF08;&#x50CF;<code>.html</code>&#xFF0C;<code>.js</code>&#xFF0C;<code>.less</code>&#xFF0C;<code>scss</code>&#xFF0C;<code>.css</code>&#x7B49;&#x4E4B;&#x7C7B;&#x7684;&#x6587;&#x4EF6;&#xFF09;&#xFF1B;&#x5B83;&#x4EEC;&#x662F;&#x4E00;&#x4E9B;&#x8FD0;&#x884C;&#x5728;<code>node.js</code>&#x73AF;&#x5883;&#x4E2D;&#x7684;&#x4E00;&#x7CFB;&#x5217;&#x51FD;&#x6570;&#xFF0C;&#x4F7F;&#x7528;&#x6211;&#x4EEC;web&#x5E94;&#x7528;&#x7A0B;&#x5E8F;&#x8D44;&#x6E90;&#x6587;&#x4EF6;&#x7684;&#x8D44;&#x6E90;&#x8DEF;&#x5F84;&#x4F5C;&#x4E3A;&#x53C2;&#x6570;&#x5E76;&#x4E14;&#x8FD4;&#x56DE;&#x5904;&#x7406;&#x540E;&#x7684;&#x65B0;&#x8D44;&#x6E90;&#x3002;</p>
<p>&#x6BD4;&#x5982;&#xFF0C;&#x4F60;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;&#x52A0;&#x8F7D;&#x5668;&#x6765;&#x544A;&#x8BC9;<code>webpack</code>&#x53BB;&#x52A0;&#x8F7D;<code>CoffeeScript</code>&#x6216;&#x8005;<code>JSX</code>&#x3002;</p>
<h2 id="%E5%8A%A0%E8%BD%BD%E5%99%A8%E7%9A%84%E7%89%B9%E6%80%A7">&#x52A0;&#x8F7D;&#x5668;&#x7684;&#x7279;&#x6027;</h2>
<ul>
<li>&#x52A0;&#x8F7D;&#x5668;&#x662F;&#x53EF;&#x4EE5;&#x88AB;&#x94FE;&#x5F0F;&#x8C03;&#x7528;&#x7684;&#xFF08;&#x5C31;&#x50CF;&#x51FD;&#x6570;&#x7684;&#x94FE;&#x5F0F;&#x8C03;&#x7528;&#x90A3;&#x6837;&#xFF09;&#x3002;&#x5B83;&#x4EEC;&#x5C31;&#x597D;&#x50CF;&#x88AB;&#x88C5;&#x5728;&#x7BA1;&#x9053;&#x4E2D;&#x4F9D;&#x6B21;&#x5BF9;&#x4F20;&#x9012;&#x8FC7;&#x6765;&#x7684;&#x8D44;&#x6E90;&#x8FDB;&#x884C;&#x5904;&#x7406;&#x3002;&#xFF08;&#x7BA1;&#x9053;&#x4E2D;&#xFF09;&#x6700;&#x540E;&#x4E00;&#x4E2A;&#x52A0;&#x8F7D;&#x5668;&#x88AB;&#x671F;&#x671B;&#x8FD4;&#x56DE;<code>javascript</code>&#x6587;&#x4EF6;&#xFF0C;&#xFF08;&#x7BA1;&#x9053;&#x4E2D;&#x7684;&#xFF09;&#x5176;&#x4F59;&#x7684;&#x52A0;&#x8F7D;&#x5668;&#x53EF;&#x4EE5;&#x8FD4;&#x56DE;&#x4EFB;&#x610F;&#x683C;&#x5F0F;&#x7684;&#xFF08;&#x5373;&#x5C06;&#x4F20;&#x9012;&#x7ED9;&#x4E0B;&#x4E00;&#x4E2A;&#x52A0;&#x8F7D;&#x5668;&#x7684;&#xFF09;&#x8D44;&#x6E90;&#x6587;&#x4EF6;&#x3002;</li>
<li>&#x52A0;&#x8F7D;&#x5668;&#x662F;&#x53EF;&#x4EE5;&#x88AB;&#x5F02;&#x6B65;&#x6216;&#x8005;&#x540C;&#x6B65;&#x8C03;&#x7528;&#x7684;&#x3002;</li>
<li>&#x52A0;&#x8F7D;&#x5668;&#x662F;&#x8FD0;&#x884C;&#x5728;<code>node.js</code>&#x7684;&#x73AF;&#x5883;&#x4E2D;&#xFF0C;&#x6240;&#x4EE5;&#x52A0;&#x8F7D;&#x5668;&#x53EF;&#x4EE5;&#x505A;&#x4EFB;&#x4F55;&#x53EF;&#x4EE5;&#x5728;&#x8FD9;&#x4E2A;&#x73AF;&#x5883;&#x4E2D;&#x53EF;&#x4EE5;&#x505A;&#x7684;&#x4E8B;&#x60C5;&#x3002;</li>
<li>&#x52A0;&#x8F7D;&#x5668;&#x53EF;&#x4EE5;&#x63A5;&#x53D7;&#x67E5;&#x8BE2;&#x53C2;&#x6570;&#xFF0C;&#x8FD9;&#x4E9B;&#x67E5;&#x8BE2;&#x53C2;&#x6570;&#x53EF;&#x4EE5;&#x4F20;&#x9012;&#x7ED9;&#x6211;&#x4EEC;&#x7684;&#x52A0;&#x8F7D;&#x5668;&#xFF0C;&#x7528;&#x6765;&#x914D;&#x7F6E;&#x6211;&#x4EEC;&#x7684;&#x52A0;&#x8F7D;&#x5668;&#x3002;</li>
<li>&#x52A0;&#x8F7D;&#x5668;&#x53EF;&#x4EE5;&#x5728;&#x914D;&#x7F6E;&#x6587;&#x4EF6;&#x4E2D;&#x901A;&#x8FC7;&#x4F7F;&#x7528;&#x6B63;&#x5219;&#x6765;&#x7ED1;&#x5B9A;&#x3002;</li>
<li>&#x52A0;&#x8F7D;&#x5668;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;<code>npm</code>&#x8FDB;&#x884C;&#x53D1;&#x5E03;&#x548C;&#x5B89;&#x88C5;&#x3002;</li>
<li>&#x666E;&#x901A;&#x7684;&#x6A21;&#x5757;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;&#x6A21;&#x5757;&#x4E2D;<code>package.json</code>&#x7684;<code>main</code>&#x6765;&#x5BFC;&#x51FA;&#x4E00;&#x4E2A;&#x52A0;&#x8F7D;&#x5668;&#x3002;</li>
<li>&#x52A0;&#x8F7D;&#x5176;&#x5B9E;&#x53EF;&#x4EE5;&#x88AB;&#x914D;&#x7F6E;&#x7684;&#x3002;</li>
<li>&#x63D2;&#x4EF6;&#x53EF;&#x4EE5;&#x7ED9;&#x52A0;&#x8F7D;&#x5668;&#x66F4;&#x591A;&#x7684;&#x529F;&#x80FD;&#x7279;&#x6027;&#x3002;</li>
<li>&#x52A0;&#x8F7D;&#x5668;&#x53EF;&#x4EE5;&#x751F;&#x6210;&#x4EFB;&#x610F;&#x5F62;&#x5F0F;&#x7684;&#x9644;&#x52A0;&#x7684;&#x6587;&#x4EF6;&#x3002;</li>
<li>&#x7B49;&#x7B49;&#x4E00;&#x4E9B;&#x7279;&#x6027;&#x3002;</li>
</ul>
<p>&#x5982;&#x679C;&#x4F60;&#x5BF9;&#x52A0;&#x8F7D;&#x5668;&#x7684;&#x4E00;&#x4E9B;&#x4F8B;&#x5B50;&#x611F;&#x5174;&#x8DA3;&#xFF0C;&#x90A3;&#x4E48;&#x53EF;&#x4EE5;&#x5230;<a href="">&#x52A0;&#x8F7D;&#x5668;&#x5217;&#x8868;</a>&#x90A3;&#x91CC;&#x53BB;&#x770B;&#x770B;&#x3002;</p>
<h1 id="%E8%A7%A3%E6%9E%90%E5%8A%A0%E8%BD%BD%E5%99%A8">&#x89E3;&#x6790;&#x52A0;&#x8F7D;&#x5668;</h1>
<p>&#x52A0;&#x8F7D;&#x5668;&#x7684;&#x89E3;&#x6790;&#x548C;&#x5176;&#x5B83;&#x6A21;&#x5757;&#x4E00;&#x6837;&#x3002;&#x4E00;&#x4E2A;&#x52A0;&#x8F7D;&#x5668;&#x6A21;&#x5757;&#x88AB;&#x671F;&#x671B;&#x80FD;&#x591F;&#x5BFC;&#x51FA;&#x4E00;&#x4E2A;&#x51FD;&#x6570;&#x5E76;&#x4E14;&#x80FD;&#x591F;&#x4E0E;<code>node.js</code>&#x5E73;&#x53F0;&#x4E0A;&#x7684;<code>JavaScript</code>&#x517C;&#x5BB9;&#x3002;&#x5728;&#x5E73;&#x5E38;&#x72B6;&#x51B5;&#x4E0B;&#x4F60;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;<code>npm</code>&#x53BB;&#x7BA1;&#x7406;&#x4F60;&#x7684;&#x52A0;&#x8F7D;&#x5668;&#xFF0C;&#x5F53;&#x7136;&#x4F60;&#x4E5F;&#x53EF;&#x4EE5;&#x628A;&#x52A0;&#x8F7D;&#x5668;&#x4F5C;&#x4E3A;&#x4F60;&#x7684;web&#x5E94;&#x7528;&#x7A0B;&#x5E8F;&#x6587;&#x4EF6;&#x3002;</p>
<h2 id="%E5%8A%A0%E8%BD%BD%E5%99%A8%E7%9A%84%E5%BC%95%E7%94%A8">&#x52A0;&#x8F7D;&#x5668;&#x7684;&#x5F15;&#x7528;</h2>
<p>&#x6309;&#x7167;&#x60EF;&#x4F8B;&#xFF0C;&#x52A0;&#x8F7D;&#x5668;&#x901A;&#x5E38;&#x90FD;&#x662F;&#x4EE5;<code>XXX-loader</code>&#x7684;&#x65B9;&#x5F0F;&#x6765;&#x547D;&#x540D;&#xFF08;&#x867D;&#x7136;&#x4E0D;&#x662F;&#x5FC5;&#x987B;&#x7684;&#xFF09;&#xFF0C;&#x5176;&#x4E2D;<code>XXX</code>&#x5C31;&#x662F;&#x8FD9;&#x4E2A;&#x52A0;&#x8F7D;&#x5668;&#x7684;&#x4E3B;&#x8981;&#x529F;&#x80FD;&#x7684;&#x63CF;&#x8FF0;&#x3002;&#x6BD4;&#x5982;&#xFF0C;<code>json-loader</code>&#x3002;</p>
<p>&#x4F60;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;&#x52A0;&#x8F7D;&#x5668;&#x7684;&#x5B8C;&#x6574;&#x540D;&#x5B57;&#xFF08;&#x6BD4;&#x5982;&#xFF1A;<code>json-loader</code>&#xFF09;&#xFF0C;&#x6216;&#x8005;&#x52A0;&#x8F7D;&#x5668;&#x7684;&#x7B80;&#x5199;&#x540D;&#x5B57;&#xFF08;&#x6BD4;&#x5982;&#xFF1A;<code>json</code>&#xFF09;&#x6765;&#x5F15;&#x7528;&#x52A0;&#x8F7D;&#x5668;&#x3002;</p>
<p>&#x52A0;&#x8F7D;&#x5668;&#x7684;&#x547D;&#x540D;&#x60EF;&#x4F8B;&#x548C;&#x4F18;&#x5148;&#x641C;&#x7D22;&#x987A;&#x5E8F;&#x662F;&#x7531;<code>webpack</code>&#x7684;&#x914D;&#x7F6E;API&#x91CC;&#x9762;&#x7684;<code>resolveLoader.moduleTemplates</code>&#x6765;&#x5B9A;&#x4E49;&#x914D;&#x7F6E;&#x7684;&#x3002;</p>
<p>&#x52A0;&#x8F7D;&#x5668;&#x7684;&#x547D;&#x540D;&#x60EF;&#x4F8B;&#x662F;&#x6709;&#x7528;&#x7684;&#xFF0C;&#x5C24;&#x5176;&#x5F53;&#x901A;&#x8FC7;<code>require()</code>&#x6765;&#x4F7F;&#x7528;&#x5B83;&#x4EEC;&#x65F6;&#xFF0C;&#x4F60;&#x53EF;&#x4EE5;&#x770B;&#x4E0B;&#x9762;&#x7684;&#x4F7F;&#x7528;&#x65B9;&#x6CD5;&#x3002;</p>
<h2 id="%E5%AE%89%E8%A3%85%E5%8A%A0%E8%BD%BD%E5%99%A8">&#x5B89;&#x88C5;&#x52A0;&#x8F7D;&#x5668;</h2>
<p>&#x5982;&#x679C;&#x52A0;&#x8F7D;&#x5668;&#x5728;<code>npm</code>&#x4E0A;&#x662F;&#x53EF;&#x4EE5;&#x5F97;&#x5230;&#x7684;&#xFF0C;&#x90A3;&#x4E48;&#x4F60;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;&#x4E0B;&#x9762;&#x7684;&#x547D;&#x4EE4;&#x6765;&#x5B89;&#x88C5;&#x52A0;&#x8F7D;&#x5668;&#xFF1A;</p>
<pre><code>    $ npm install xxx-loader --save
</code></pre><p>&#x6216;&#x8005;&#x4F7F;&#x7528;&#xFF1A;</p>
<pre><code>    $ npm install xxx-loader --save-dev
</code></pre><h1 id="%E4%BD%BF%E7%94%A8%E5%8A%A0%E8%BD%BD%E5%99%A8">&#x4F7F;&#x7528;&#x52A0;&#x8F7D;&#x5668;</h1>
<p>&#x6709;&#x8BB8;&#x591A;&#x65B9;&#x6CD5;&#x53EF;&#x4EE5;&#x5728;&#x4F60;&#x7684;web&#x5E94;&#x7528;&#x4E2D;&#x4F7F;&#x7528;&#x52A0;&#x8F7D;&#x5668;&#xFF1A;</p>
<ul>
<li>&#x4F7F;&#x7528;<code>require</code>&#x8BED;&#x53E5;</li>
<li>&#x901A;&#x8FC7;&#x914D;&#x7F6E;&#x6587;&#x4EF6;&#x7684;&#x914D;&#x7F6E;</li>
<li>&#x901A;&#x8FC7;<code>CLI</code>&#x914D;&#x7F6E;</li>
</ul>
<h2 id="%E9%80%9A%E8%BF%87-require-%E4%BD%BF%E7%94%A8%E5%8A%A0%E8%BD%BD%E5%99%A8">&#x901A;&#x8FC7;<code>require</code>&#x4F7F;&#x7528;&#x52A0;&#x8F7D;&#x5668;</h2>
<blockquote>
<p><strong>&#x6CE8;</strong>&#xFF1A;&#x867D;&#x7136;&#x8FD9;&#x79CD;&#x65B9;&#x5F0F;&#x662F;&#x53EF;&#x4EE5;&#x7684;&#xFF0C;&#x4F46;&#x662F;&#x5C3D;&#x91CF;&#x907F;&#x514D;&#x8FD9;&#x6837;&#x505A;&#xFF0C;&#x9664;&#x975E;&#x4F60;&#x60F3;&#x8BA9;&#x4F60;&#x7684;&#x4EE3;&#x7801;&#x5728;&#x73AF;&#x5883;&#x4E2D;&#xFF08;<code>node.js</code>&#x548C;&#x6D4F;&#x89C8;&#x5668;&#xFF09;&#x662F;&#x4E0D;&#x53D7;&#x63A7;&#x5236;&#x7684;&#x3002;&#x4F7F;&#x7528;&#x6307;&#x5B9A;&#x7684;&#x52A0;&#x8F7D;&#x5668;&#x7684;&#x914D;&#x7F6E;&#x7EA6;&#x5B9A;&#xFF08;&#x89C1;&#x4E0B;&#x4E00;&#x8282;&#xFF09;&#x3002;</p>
</blockquote>
<p>&#x4E5F;&#x53EF;&#x4EE5;&#x5728;<code>require</code>&#xFF08;&#x6216;&#x8005;<code>define</code>&#xFF0C;<code>require.ensure</code>&#xFF09;&#x8BED;&#x53E5;&#x4E2D;&#x6307;&#x5B9A;&#x4F7F;&#x7528;&#x52A0;&#x8F7D;&#x5668;&#x3002;&#x53EA;&#x9700;&#x8981;&#x5C06;&#x52A0;&#x8F7D;&#x5668;&#x548C;&#x8D44;&#x6E90;&#x6587;&#x4EF6;&#x7684;&#x8DEF;&#x5F84;&#x4E4B;&#x95F4;&#x4F7F;&#x7528;<code>!</code>&#x5206;&#x5F00;&#xFF0C;&#x8BED;&#x53E5;&#x4E2D;&#x6BCF;&#x4E00;&#x4E2A;&#x90E8;&#x5206;&#x90FD;&#x662F;&#x76F8;&#x5BF9;&#x4E8E;&#x5F53;&#x524D;&#x6587;&#x4EF6;&#x8DEF;&#x5F84;&#x7684;&#x3002;</p>
<pre><code>    require(&quot;./loader!./dir/file.txt&quot;);
    // =&gt; uses the file &quot;loader.js&quot; in the current directory to transform
    //    &quot;file.txt&quot; in the folder &quot;dir&quot;.

    require(&quot;jade!./template.jade&quot;);
    // =&gt; uses the &quot;jade-loader&quot; (that is installed from npm to &quot;node_modules&quot;)
    //    to transform the file &quot;template.jade&quot;

    require(&quot;!style!css!less!bootstrap/less/bootstrap.less&quot;);
    // =&gt; the file &quot;bootstrap.less&quot; in the folder &quot;less&quot; in the &quot;bootstrap&quot;
    //    module (that is installed from github to &quot;node_modules&quot;) is
    //    transformed by the &quot;less-loader&quot;. The result is transformed by the
    //    &quot;css-loader&quot; and then by the &quot;style-loader&quot;.
</code></pre><h2 id="%E9%85%8D%E7%BD%AE">&#x914D;&#x7F6E;</h2>
<p>&#x4F60;&#x4E5F;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;&#x914D;&#x7F6E;&#x6587;&#x4EF6;&#x901A;&#x8FC7;&#x4F7F;&#x7528;&#x6B63;&#x5219;&#x6765;&#x7ED1;&#x5B9A;&#x4F60;&#x7684;&#x52A0;&#x8F7D;&#x5668;</p>
<pre><code>    {
        module: {
            loaders: [
                    { test: /\.jade$/, loader: &quot;jade&quot; },
                    // =&gt; &quot;jade&quot; loader is used for &quot;.jade&quot; files

                { test: /\.css$/, loader: &quot;style!css&quot; },
                // =&gt; &quot;style&quot; and &quot;css&quot; loader is used for &quot;.css&quot; files
                // Alternative syntax:
                { test: /\.css$/, loaders: [&quot;style&quot;, &quot;css&quot;] },
            ]
        }
    }
</code></pre><h2 id="cli">CLI</h2>
<p>&#x4F60;&#x4E5F;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;&#x4F7F;&#x7528;<code>CLI</code>&#x6765;&#x7ED1;&#x5B9A;&#x52A0;&#x8F7D;&#x5668;</p>
<pre><code>    $ webpack --module-bind jade --module-bind &apos;css=style!css&apos;
</code></pre><p>&#x4E0A;&#x9762;&#x7684;&#x547D;&#x4EE4;&#x4F7F;&#x7528;<code>jade</code>&#x52A0;&#x8F7D;&#x5668;&#x5E94;&#x7528;&#x5230;<code>.jade</code>&#x6587;&#x4EF6;&#x4E2D;&#xFF0C;&#x4F7F;&#x7528;<code>style</code>&#x548C;<code>css</code>&#x52A0;&#x8F7D;&#x5668;&#x5E94;&#x7528;&#x5230;<code>.css</code>&#x6587;&#x4EF6;&#x4E2D;&#x3002;</p>
<h2 id="%E6%9F%A5%E8%AF%A2%E5%8F%82%E6%95%B0">&#x67E5;&#x8BE2;&#x53C2;&#x6570;</h2>
<p>&#x52A0;&#x8F7D;&#x5668;&#x53EF;&#x4EE5;&#x63A5;&#x53D7;&#x67E5;&#x8BE2;&#x53C2;&#x6570;&#xFF0C;&#x901A;&#x8FC7;&#x4E00;&#x4E2A;&#x67E5;&#x8BE2;&#x7684;&#x5B57;&#x7B26;&#x4E32;&#xFF08;&#x5C31;&#x50CF;&#x5728;web&#x4F7F;&#x7528;&#x7684;&#x67E5;&#x8BE2;&#x53C2;&#x6570;&#x90A3;&#x6837;&#xFF09;&#xFF1B;&#x67E5;&#x8BE2;&#x53C2;&#x6570;&#x662F;&#x7D27;&#x8DDF;&#x5728;&#x52A0;&#x8F7D;&#x5668;&#x7684;&#x540E;&#x9762;&#x5E76;&#x4E14;&#x524D;&#x9762;&#x6709;&#x4E00;&#x4E2A;<code>?</code>&#x7B26;&#x53F7;&#x3002;&#x4E3E;&#x4E2A;&#x4F8B;&#x5B50;&#xFF1A;<code>url-loader?mimetype=image/png</code>&#x3002;</p>
<p><strong>&#x6CE8;</strong>&#xFF1A;&#x67E5;&#x8BE2;&#x5B57;&#x7B26;&#x4E32;&#x7684;&#x683C;&#x5F0F;&#x53D6;&#x51B3;&#x4E8E;&#x52A0;&#x8F7D;&#x5668;&#x3002;&#x4F7F;&#x7528;&#x524D;&#x6700;&#x597D;&#x770B;&#x4E00;&#x4E0B;&#x90A3;&#x4E2A;&#x52A0;&#x8F7D;&#x5668;&#x7684;&#x6587;&#x6863;&#x3002;&#x8BB8;&#x591A;&#x52A0;&#x8F7D;&#x5668;&#x63A5;&#x6536;&#x53C2;&#x6570;&#x7684;&#x5F62;&#x5F0F;&#x90FD;&#x662F;&#x6BD4;&#x8F83;&#x6B63;&#x5E38;&#x7684;&#xFF08;<code>?key=value&amp;key2=value2</code>&#xFF09;&#x6216;&#x8005;<code>JSON</code>&#x683C;&#x5F0F;&#xFF08;<code>?{&quot;key&quot;:&quot;value&quot;, &quot;key2&quot;: &quot;value2&quot;}</code>&#xFF09;&#x3002;</p>
<h3 id="%E5%9C%A8-require-%E4%B8%AD%E4%BD%BF%E7%94%A8">&#x5728;<code>require</code>&#x4E2D;&#x4F7F;&#x7528;</h3>
<pre><code>    require(&quot;url-loader?mimetype=image/png!./file.png&quot;);
</code></pre><h3 id="%E5%9C%A8%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6%E4%B8%AD">&#x5728;&#x914D;&#x7F6E;&#x6587;&#x4EF6;&#x4E2D;</h3>
<pre><code>    { test: /\.png$/, loader: &quot;url-loader?mimetype=image/png&quot; }
</code></pre><p>&#x6216;&#x8005;</p>
<pre><code>    {
        test: /\.png$/,
        loader: &quot;url-loader&quot;,
        query: { mimetype: &quot;image/png&quot; }
    }
</code></pre><h3 id="%E5%9C%A8-cli-%E4%B8%AD">&#x5728;<code>CLI</code>&#x4E2D;</h3>
<pre><code>    webpack --module-bind &quot;png=url-loader?mimetype=image/png&quot;
</code></pre>
                    
                    </section>
                
                
                </div>
            </div>
        </div>

        
        <a href="../start/vendor-modules.html" class="navigation navigation-prev " aria-label="Previous page: Vendor Modules"><i class="fa fa-angle-left"></i></a>
        
        
        <a href="../start/using-plugins.html" class="navigation navigation-next " aria-label="Next page: Using Plugins"><i class="fa fa-angle-right"></i></a>
        
    </div>
</div>

        
<script src="../gitbook/app.js"></script>

    
    <script src="../gitbook/plugins/gitbook-plugin-disqus/plugin.js"></script>
    

<script>
require(["gitbook"], function(gitbook) {
    var config = {"fontSettings":{"theme":null,"family":"sans","size":2},"disqus":{"shortName":"iwebpack"}};
    gitbook.start(config);
});
</script>

        
    </body>
    
</html>
